﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Utility.Events;

namespace TimeTracker.EditForms
{
    public partial class AddProject : Form
    {
        protected IProject Project
        {
            get;
            set;
        }
        
        public AddProject()
            : this(null)
        {
            
        }

        public AddProject(IProject project)
        {
            InitializeComponent();

            this.Project = project;
            this.project1.Name = String.Empty;
        }

        public event EventHandler<EventArgs<IProject>> Saved;

        private void button1_Click(object sender, EventArgs e)
        {
            IProject project = Manager.Instance.CreateProject(this.Project, this.project1.Name);

            Manager.Instance.Save();

            this.Saved.Fire(sender, project);

            this.Close();
        }
    }
}
